package flc.ast.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class ClassicAdapter extends StkProviderMultiAdapter<StkResBean> {

    public ClassicAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(205));
        addItemProvider(new ClassicProvider());
    }

    private class ClassicProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_classic;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getThumbUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivClassicItemImg));
            baseViewHolder.setText(R.id.tvClassicItemName, bean.getName());
            baseViewHolder.setText(R.id.tvClassicItemDesc,bean.getDesc());
            if (baseViewHolder.getBindingAdapterPosition()==0){
                baseViewHolder.getView(R.id.llClassicItem2).setBackgroundResource(R.drawable.shape_classic2);
                baseViewHolder.getView(R.id.llClassicItem1).setBackgroundResource(R.drawable.shape_classic1);
                baseViewHolder.setTextColor(R.id.tvClassicItemName, Color.parseColor("#FFFFFFFF"));
            }else{
                baseViewHolder.getView(R.id.llClassicItem2).setBackgroundResource(R.drawable.shape_classic1);
                baseViewHolder.getView(R.id.llClassicItem1).setBackgroundResource(R.drawable.shape_classic2);
                baseViewHolder.setTextColor(R.id.tvClassicItemName, Color.parseColor("#FF000000"));
            }
        }
    }

}
